import csv
import pandas as pd
from tqdm import tqdm
import numpy as np
import os
from sklearn import preprocessing

def read_data(file_path):
    # file_path = "G:\\粤港澳数模\\附件：相关股票数据\\000028.SZ.xlsx"
    df_file_data = pd.read_csv(file_path, encoding='gb2312')
    return df_file_data


if __name__ == "__main__":
    file_path = 'G:\\粤港澳数模\\归一化之后的数.csv'
    df_file_data = read_data(file_path)
    print(df_file_data)
    new_list = []
    for index ,row in tqdm(df_file_data.iterrows()):
        num = 0.2 * row['mean_num_perday'] + 0.1 * row['mean_sum_perday'] + 0.15 * row['mean_num_per5min'] + 0.1 * \
            row['mean_sum_per5min'] + 0.1 * (1 - row['std_num_per5min']) + 0.1 * (1 - row['std_sum_per5min']) + \
            0.1 * (1 - row['mean_high_low_distance_permin']) + 0.15 * (1 - row['std_high_low_distance_permin'])
        new_list.append(num)

    print(new_list)
    # new_list.sort(reverse=True)
    # print(new_list)
    df_file_data['score'] = new_list
    print(df_file_data)
    df_score = df_file_data[['stock_name', 'score']]
    df_score.to_csv("G:\\粤港澳数模\\score.csv")